/* global storage */
const getStorage = async (key) => {
  try {
    const res = await storage.load({
      key,
      autoSync: true,
      syncInBackground: true,
    });
    return res;
  } catch (err) {
    return err.name;
  }
};

const saveStorage = (key, value) => {
  storage.save({
    key,
    rawData: {
      value,
    },
    expires: 1000 * 3600 * 24 * 365,
  });
};
const removeStorage = (key) => {
  storage.remove({
    key,
  });
};
export default {
  getStorage,
  saveStorage,
  removeStorage,
};
